<?php

namespace app\admin\model\wk;

use think\Model;


class Teacher extends Model
{

    

    

    // 表名
    protected $name = 'wk_teacher';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'label_list_text',
        'status_text'
    ];
    

    
    public function getLabelListList()
    {
        return ['公考' => __('公考'), '行测' => __('行测'), '申论' => __('申论'), '面试' => __('面试'), '常识' => __('常识'), '数量' => __('数量'), '资料' => __('资料'), '言语' => __('言语'), '逻辑' => __('逻辑')];
    }

    public function getStatusList()
    {
        return ['normal' => __('Status normal'),'hidden' => __('Status hidden')];
    }


    public function getLabelListTextAttr($value, $data)
    {
        $value = $value ?: ($data['label_list'] ?? '');
        $valueArr = explode(',', $value);
        $list = $this->getLabelListList();
        return implode(',', array_intersect_key($list, array_flip($valueArr)));
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    protected function setLabelListAttr($value)
    {
        return is_array($value) ? implode(',', $value) : $value;
    }


}
